#ifndef NR_DEVICE_ITEM_H
#define NR_DEVICE_ITEM_H

#include "nr_object.h"
#include "nr_device.h"
#include "nr_device_property.h"
#include "nr_device_type.h"

class nr_device_item : public nr_object
{
public:
    typedef QHash<nr_id_t, nr_device_property*> nr_device_property_hash;
    typedef QHash<nr_device_id_t, nr_device_item*> nr_device_item_hash;
        
public:
    nr_device_item();
    nr_device_item(nr_device_item& item);
    ~nr_device_item();

    nr_device_item& operator = (nr_device_item &item);

    nr_device_id_t& id() { return m_id; }
    QString& name() { return m_name; }
    nr_device_item*& parent_item() { return m_parent_item; }

    nr_device_type*& device_type() { return m_device_type; };
    nr_device*& device() { return m_device; }
    
    nr_error_t init_device();

    nr_device_property_hash& properties() { return m_properties; }
    nr_device_item_hash& items() { return m_device_items; }
    
    virtual nr_device_item* find_device_item_by_id(const nr_device_id_t &device_id);

    virtual void serialize(QDataStream& data_stream);
    virtual void deserialize(QDataStream& data_stream);

protected:
    void copy_data(nr_device_item& item);

    nr_device_id_t m_id;
    QString m_name;
    nr_device_item *m_parent_item;
    
    nr_device_type *m_device_type;
    nr_device *m_device; 
    
    nr_device_property_hash m_properties;
    nr_device_item_hash m_device_items;
};

typedef nr_device_item::nr_device_property_hash nr_device_properties;
typedef nr_device_item::nr_device_item_hash nr_device_items;

#endif // NR_DEVICE_ITEM_H
